import { memo } from "react";
import MyDialog from "../MyDialog";
import MyButton from "../MyButton";
import './index.scss'


interface ConfirmDialogProps {
    visible: boolean;
    onClose: Function;
    onConfirm: Function;
    confirmText?: string;
    cancelText?: string;
    tipText?: string;
    title?: string;
}

const tipTextA = '确定要进行此操作吗'

const ConfirmDialog = memo(({visible,onClose,onConfirm,confirmText='确定',cancelText='取消',tipText=tipTextA,title='提示'}:ConfirmDialogProps)=>{

    function handleOnClose(){
        onClose && onClose()
    }
    function handleOnConfirm(){
        onConfirm && onConfirm()
    }
    return (
        <>
            <MyDialog visible={visible} title={title} onClose={handleOnClose}>
                <div className='exit_dlg'>
                    <div className="exit_dlg_body">
                        {tipText}
                    </div>

                    <div className="exit_dlg_footer">
                        <MyButton 
                            name={cancelText} 
                            type='guest'
                            onClick={handleOnClose}
                        />
                        <MyButton 
                            name={confirmText}
                            type='danger'
                            onClick={handleOnConfirm}
                        />
                    </div>

                </div>
            </MyDialog>
        </>
    )
})

export default ConfirmDialog;